// pages/form/button/opentype.js
Page({
    

    handleContact:function(e){

        console.log("联系客服的回调:")
        console.log(e)
    },

    onShareAppMessage:function(obj){
        return {
            title: '自定义转发标题',
            path: 'pages/form/button/opentype',
            imageUrl:'https://www.fulfill.com.cn/wechat/imgs/logo.png' 
          } 
    },

    hanldeGetUserInfo:function(e){
        console.log(e);
    },
    login:function(e){
        wx.login({
            success(res){
                console.log(res);
            }
        })
    },
    fullLogin:function(e){
        let that = this;
        wx.login({
            success(res){
                
                wx.getUserInfo({
                    success(ret){
                        //console.log(ret); 明文，不包含openid
                        that.getToken(
                                    res.code,
                                    ret.encryptedData,
                                    ret.iv,
                                    ret.signature,
                                    ret.rawData
                            );
                    }
                })
            }
        })
       

    },
    getToken(code,encryptedData,iv,signature,rawData){
        console.log("code:   "+code);
        console.log("encryptedData:   "+encryptedData);
        console.log("signature:   "+signature);
        console.log("rawData:   "+rawData);
        // debugger;
        wx.request({
            method:'GET',
            url:'http://192.168.77.11/api/v1/user/wxlogin',
            // url:'http://192.168.77.11/api/v1/user/code2Session',
            dataType:'json',
            data:{
                "code":code,
                // "js_code":'031afwFa1PrpRA00hOGa1yxXS82afwFg',
                "encryptedData":encryptedData,
                "iv":iv,
                "signature":signature,
                "rawData":rawData
            },
            success(resp){
                console.log("获取Token:");
                console.log(resp);
            }
        });
    }






})